package top.yjp.jtf.plugin;

import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorPolicy;
import com.intellij.openapi.fileEditor.FileEditorProvider;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;

public class ExcelFileEditorProvider implements FileEditorProvider {
    @Override
    public boolean accept(@NotNull Project project, @NotNull VirtualFile virtualFile) {
        String fileName = virtualFile.getName().toLowerCase();
        return fileName.endsWith(".xlsx"); // 检查文件扩展名
    }

    @Override
    public @NotNull FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile virtualFile) {
        return new ExcelFileEditor(project, virtualFile);
    }

    @Override
    public @NotNull String getEditorTypeId() {
        return "ExcelEditor"; // 唯一标识符
    }

    @Override
    public @NotNull FileEditorPolicy getPolicy() {
        return FileEditorPolicy.PLACE_AFTER_DEFAULT_EDITOR; // 或使用其他适合的策略
    }
}
